package ytt.spec.edu.week12_class01;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class FirstAdapter extends ArrayAdapter<First> {
    private int itemLayout;

    public FirstAdapter(Context context, int resource,  List<First> objects) {
        super(context, resource, objects);
       itemLayout=resource;
    }
    @Override
    public View getView(int position, View convertView,  ViewGroup parent) {
     First first=getItem(position);
     View view=LayoutInflater.from(getContext()).inflate(itemLayout,parent,false);
     ImageView firstImage=(ImageView) view.findViewById(R.id.image);
     TextView firstName=(TextView) view.findViewById(R.id.name);
     TextView firstContent=(TextView) view.findViewById(R.id.content);
     firstImage.setImageResource(first.getImageId());
     firstName.setText(first.getName());
     firstContent.setText(first.getContent());
     return view;
    }
}
